#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,k,N;
	cin>>n>>k;
	N=n;
	while(n>k)
	{
		N=N+n/k;
		n=n%k+n/k;
	}
	cout<<N<<endl;
	system("pause");
	return 0; 
}
